package com.yupi.soulba.once;

import com.alibaba.excel.EasyExcel;

import java.util.List;

/**
 * 导入Excel
 * @author 黄云杰、过江辉 
 */
public class ImportExcel {
    
    /**
     * 读取数据
     */
    public static void main(String[] args) {
        
        String fileName = "C:\\XingQiuCode\\SoulBa\\soulba-backend\\src\\main\\resources\\testExcel.xlsx";
        readByListener(fileName);
        synchronousRead(fileName);
        
    }

    /**
     * 监听器读
     * @param fileName
     */
    public static void readByListener(String fileName){
        EasyExcel.read(fileName, XingQiuTableUserInfo.class, new TableListener()).sheet().doRead();
    }

    /**
     * 同步读
     * @param fileName
     */
    public static void synchronousRead(String fileName) {
        List<XingQiuTableUserInfo> totalDataList = 
                EasyExcel.read(fileName)
                        .head(XingQiuTableUserInfo.class)
                        .sheet().doReadSync();
        for (XingQiuTableUserInfo xingQiuTableUserInfo : totalDataList) {
            System.out.println(xingQiuTableUserInfo);
        }
    
    }
    
}
